from weibosender.db.sql_helper import SqlHelper


class SenderLimitLogDAL:

    _sql_now_log_count = 'select count(0) from "senders_limit_log" where date(created)=date(\'now\', \'localtime\');'
    _sql_insert = 'INSERT INTO senders_limit_log(uid,content) VALUES(?,?);'

    @staticmethod
    def write_log(log):
        return SqlHelper.execute(SenderLimitLogDAL._sql_insert, log)

    # 获取当天发送私信已达极限的用户数量
    @staticmethod
    def get_now_log_count():
        result = SqlHelper.execute(SenderLimitLogDAL._sql_now_log_count)
        if not result or len(result) == 0:
            return 0
        return result[0]